package com.ifgi.sitcom.campusmapperNDrawer.views;

import java.util.ArrayList;
import java.util.List;

import org.osmdroid.views.MapView;
import org.osmdroid.views.overlay.ItemizedIconOverlay;
import org.osmdroid.views.overlay.OverlayItem;

import com.gamificationlibrary.fragment.SpinnerLeaderboardsFragment;
import com.gamificationlibrary.model.leaderboard.Leaderboard;
import com.gamificationlibrary.model.*;
import com.ifgi.sitcom.campusmapperNDrawer.R;
import com.ifgi.sitcom.campusmapperNDrawer.controllers.*;
import com.ifgi.sitcom.campusmapperNDrawer.dialogs.*;
import com.ifgi.sitcom.campusmapperNDrawer.dialogs.ExistingPlanDialog.ExistingPlanDialogListener;
import com.ifgi.sitcom.campusmapperNDrawer.fragments.MapFragment;
import com.ifgi.sitcom.campusmapperNDrawer.indoordata.*;
import com.ifgi.sitcom.campusmapperNDrawer.io.*;
import com.ifgi.sitcom.campusmapperNDrawer.outdoordata.*;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.Log;

public class MyItemizedIconOverlay extends ItemizedIconOverlay<OverlayItem> {
    protected Context mContext;

    public MyItemizedIconOverlay(final Context context,final List<OverlayItem> aList) {
         super(context, aList, new OnItemGestureListener<OverlayItem>() {
                @Override public boolean onItemSingleTapUp(final int index, final OverlayItem item) {
                        return false;
                }
                @Override public boolean onItemLongPress(final int index, final OverlayItem item) {
                        return false;
                }
              } );
        // TODO Auto-generated constructor stub
         mContext = context;
    }

    @Override 
    protected boolean onSingleTapUpHelper(final int index, final OverlayItem item, final MapView mapView) 
    { 
    	 MenuListDialog menu=new MenuListDialog();
    	 
    	 android.support.v4.app.FragmentManager fm = ((FragmentActivity) mContext).getSupportFragmentManager();
		 MapFragment fragment = (MapFragment) fm.findFragmentByTag("mapFragment");
		 Bundle b=new Bundle();

		 if(item.getDrawable().getCurrent().getConstantState().equals(fragment.getActivity().getResources().getDrawable(R.drawable.buildingwhite_).getConstantState()))
		 {
			 b.putString("put_lookOwners", "no"); 
		 }
		 else  b.putString("put_lookOwners", "yes");
			 
    	 b.putString("item_name", item.getTitle());
    	 b.putString("item_URI", item.getSnippet());
    	 
    	
 
    	 menu.setArguments(b);
         menu.show(((FragmentActivity) mContext).getSupportFragmentManager(), "menu");
        
    	 return true;
    }
    
    
    
}